using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.Net.Mail;
using Decav.Reality;

namespace Decav.Gatsb.Application.CommandWorkflow
{
    /// <summary>
    /// Sends an SMS message to the currently authenticated user.
    /// </summary>
	public partial class SendUserSmsActivity: Activity
	{
		public SendUserSmsActivity()
		{
			InitializeComponent();
		}

        /// <summary>
        /// The dependency property that gets or sets the body of the message to send.
        /// </summary>
        public static DependencyProperty MessageBodyProperty = DependencyProperty.Register(
            "MessageBody", typeof(string), typeof(SendUserSmsActivity));

        /// <summary>
        /// Gets or sets the body of the message to send.
        /// </summary>
        [ValidationOption(ValidationOption.Required)]
        public string MessageBody
        {
            get { return (string)GetValue(MessageBodyProperty); }
            set { SetValue(MessageBodyProperty, value); }
        }

        /// <summary>
        /// The dependency property that gets or sets the sending address.
        /// </summary>
        public static DependencyProperty SendingAddressProperty = DependencyProperty.Register(
            "SendingAddress", typeof(string), typeof(SendUserSmsActivity));

        /// <summary>
        /// Gets or sets the sending address.
        /// </summary>
        [ValidationOption(ValidationOption.Required)]
        public string SendingAddress
        {
            get { return (string)GetValue(SendingAddressProperty); }
            set { SetValue(SendingAddressProperty, value); }
        }
        

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            GatsbApplication.Current.SendUserSms(new EmailAddress(SendingAddress), MessageBody);
            return ActivityExecutionStatus.Closed;
        }
        
	}
}
